#!/bin/sh
# List of artwork sizes:
# Settings: 29 (old iPad), 58 (Retina iPad, 29@2x), 87 (iPhone6+, 29@3x)
# Spotlight: 40 (old iPad), 80 (Retina iPad 40@2x), 120 (iPhone6+, 40@3x)
# Notification: 40 (old iPhone, 20@2x), 60 (iPhone 6+, 20@3x)
# AppStore: 1024 (@1x)
# App Icon: 76 (old iPad), 152 (Retina iPad, 76@2x), 167 (iPad Pro 83.5@2x),
#           57 (old iPhone), 120 (iPhone, 60@2x), 180 (new iPhone, 60@3x)
sizes="20 29 40 57 58 60 72 76 80 87 120 152 167 180 1024"

# create a dummy splash image to get full screen on retina displays
# a custom image can be provided (portrait)
splash_src="$appsrcdir/splash.png"

splash_update=no
if [ ! -f "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default.png" ]; then
  splash_update=yes
fi
if [ -f "$splash_src" ] && [ `isnewer "$splash_src" "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default.png"` = yes ]; then
  splash_update=yes
fi

if [ $splash_update = yes ]; then
  if [ -f "$splash_src" ]; then
    echo " => generating splash images.."
    convert $splash_src -resize 320x480\!   "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default.png"
    convert $splash_src -resize 640x960\!   "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default@2x.png"
    convert $splash_src -resize 640x1136\!  "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-568h@2x.png"
    convert $splash_src -resize 750x1334\!  "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-667h@2x.png"
    convert $splash_src -resize 1242x2208\! "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-736h@2x.png"
    convert $splash_src -resize 768x1024\!  "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-Portrait.png"
    convert $splash_src -resize 1536x2048\! "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-Portrait@2x.png"
  else
    echo " => generating default splash images.."
    convert -size 320x480   xc:black "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default.png"
    convert -size 640x960   xc:black "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default@2x.png"
    convert -size 640x1136  xc:black "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-568h@2x.png"
    convert -size 750x1334  xc:black "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-667h@2x.png"
    convert -size 1242x2208 xc:black "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-736h@2x.png"
    convert -size 768x1024  xc:black "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-Portrait.png"
    convert -size 1536x2048 xc:black "$SYS_PREFIXROOT/build/$SYS_APPNAME/Default-Portrait@2x.png"
  fi
fi

#eof
